package com;

import java.io.IOException;

import javax.servlet.AsyncContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DemoAsyncListenerServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		ServletOutputStream out = response.getOutputStream();
		AsyncContext context = request.startAsync();
		context.setTimeout(60 * 60 * 1000);
		System.out.println(Thread.currentThread().getName() + " main");
		out.setWriteListener(new WriteListener() {

			@Override
			public void onWritePossible() throws IOException {

			}

			@Override
			public void onError(Throwable throwable) {

			}

		});

	}

}
